import type {
  MenuDataItem,
  BasicLayoutProps as ProLayoutProps,
  Settings,
} from '@ant-design/pro-layout';
import ProLayout from '@ant-design/pro-layout';
import React from 'react';
import { useIntl, useModel } from 'umi';

export type NormalLayoutProps = {
  breadcrumbNameMap: Record<string, MenuDataItem>;
  route: ProLayoutProps['route'] & {
    authority: string[];
  };
  settings: Settings;
} & ProLayoutProps;

export type NormalLayoutContext = { [K in 'location']: NormalLayoutProps[K] } & {
  breadcrumbNameMap: Record<string, MenuDataItem>;
};

const NormalLayout: React.FC<NormalLayoutProps> = (props) => {
  const {
    children,
  } = props;
  const { initialState } = useModel('@@initialState');
  const { formatMessage } = useIntl();

  return (
    <ProLayout
      formatMessage={formatMessage}
      {...props}
      title={initialState?.settings?.title}
      pure={true}
    >
      {children}
    </ProLayout>
  );
};

export default NormalLayout;